package servlet.Student;

import bean.Student;
import dao.impl.StudentIDaoImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/studentAllServlet")
public class StudentAllServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        StudentIDaoImp studentIDao = new StudentIDaoImp();
        List<Student> students = studentIDao.getStudentsAll();
        HttpSession session = req.getSession();
        System.out.println(students);
        session.setAttribute("studentList", students);
        resp.sendRedirect("/student/showStudent.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}